package practica.arboles;

import org.antlr.runtime.Token;
import org.antlr.runtime.tree.CommonTree;

public class MiArbol extends CommonTree {

	private boolean valido = false;
	private int columna;
	private int linea;
	private float valor;
	private boolean evaluado = false;
	
	
	public MiArbol() {

	}
	public MiArbol(Token t) {
		super(t);

		if (t != null) {
			columna = t.getCharPositionInLine();
			linea = t.getLine();
			valido = true;
		}     
	}

	public MiArbol (Token t, String file){
		super(t);

		if (t != null) {
			columna = t.getCharPositionInLine();
			linea = t.getLine();
			valido = true;
		}     
	}
	public int getColumna() {
		return columna;
	}

	public void setColumna(int columna) {
		this.columna = columna;
	}

	public int getLinea() {
		return linea;
	}

	public void setLinea(int linea) {
		this.linea = linea;
	}
	public void setValor(float valor) {
		this.valor = valor;
		evaluado = true;
	}
    
	public String toString() {

		StringBuffer sb = new StringBuffer("");

		sb.append(super.toString());

		if (valido) {
			sb.append(" (linea: ");
			sb.append(linea);
			sb.append(", columna: ");
			sb.append(columna);
			if (evaluado){
                sb.append(", valor: ");
                sb.append(valor);
			}
			sb.append(")");
		}

		return sb.toString();
	}
}